package enums.enumSet;

import java.util.EnumSet;
import java.util.Set;

public class Text {

	public enum Style {
		BOLD, ITALIC, UNDERLINE, STRIKETHROUGH
	}

	public void applyStyles(Set<Style> styles) {
		System.out.println("all styles:");
		for (Style style : styles) {
			System.out.println("style-" + style);
		}
	}
	
	private void test1() {
		applyStyles(EnumSet.of(Style.BOLD, Style.UNDERLINE));

		applyStyles(EnumSet.of(Style.BOLD, Style.UNDERLINE, Style.ITALIC));
		
		applyStyles(EnumSet.allOf(Style.class));
		
		applyStyles(EnumSet.complementOf(EnumSet.of(Style.BOLD, Style.UNDERLINE)));
		
		applyStyles(EnumSet.range(Style.ITALIC, Style.UNDERLINE));
	}
	
	private void test2() {
		EnumSet<Style> set = EnumSet.noneOf(Style.class);
		set.add(Style.BOLD);
		
		set.forEach(s->System.out.printf("e:" + s));
	}
	
	private void test3() {
		Class<Style> class1 = Style.ITALIC.getDeclaringClass();
		Class<Style> class2 = Style.UNDERLINE.getDeclaringClass();
		

		Class<? extends Style> class3 = Style.ITALIC.getClass();
		Class<?> class4 = Style.UNDERLINE.getClass();
		
		if (class1 == class2) {
			System.out.println("Style.ITALIC.getDeclaringClass() == Style.UNDERLINE.getDeclaringClass()");
		} else {
			System.out.println("Style.ITALIC.getDeclaringClass() != Style.UNDERLINE.getDeclaringClass()");
		}
		
		if (class1 == class3) {
			System.out.println("Style.ITALIC.getDeclaringClass() == Style.ITALIC.getClass()");
		} else {
			System.out.println("Style.ITALIC.getDeclaringClass() != Style.ITALIC.getClass()");
		}
		
		if (class3 == class4) {
			System.out.println("Style.ITALIC.getClass() == Style.UNDERLINE.getClass()");
		} else {
			System.out.println("Style.ITALIC.getClass() != Style.UNDERLINE.getClass()");
		}
	}

	public static void main(String[] args) {
		Text text = new Text();
		
		int outType = 3;
		
		switch(outType) {
		case 1:
			text.test1();
			break;
		case 2:
			text.test2();
			break;
		case 3:
			text.test3();
			break;
		default:
		}
		
	}
}
